REPLICATION FILES FOR EDMOND, MIDRIGAN, AND XU "COMPETITION, MARKUPS, AND THE GAINS FROM INTERNATIONAL TRADE" (AER, FORTHCOMING).  

The attached zip file contains Matlab and Stata code to reproduce all the results in the main text and online Appendix.

This code draws on a number of standard Matlab toolboxes and also on the CompEcon toolbox by Miranda and Fackler, available here:

http://www4.ncsu.edu/~pfackler/compecon/toolbox.html

The zip file contains the following key folders:

* Data
* Benchmark model
* Robustness and sensitivity analysis
* Extensions

each with several subfolders.

Below, Section I outlines our Matlab and Stata code for processing the data and our Matlab code for solving the benchmark model. Section II outlines the code used for our robustness checks and sensitivity analysis (including experiments reported both in the main text and in the online Appendix). Section III outlines the code used for more elaborate extensions (capital accumulation and elastic labor supply; asymmetric countries; free entry and collusion). Section IV provides notes on reproducing each of the tables in the main text. Section V provides notes on each of the tables in the online Appendix.

Please let us know if you have any questions about running these programs or reproducing any of our results.

Sincerely,

Chris Edmond
Virgiliu Midrigan
Daniel Yi Xu

March 2015





I. DATA AND BENCHMARK MODEL

I.1 DATA

* DATA DISCLOSURE

The main data we used for this paper is from the "Taiwanese Annual Survey of Manufacturing" (2000--2004).  The micro-level data is proprietary and was purchased from the Ministry of Economic Affairs (MOEA) of Taiwan under a confidentiality agreement. 

For more detailed information of this data, please refer to 
http://www.moea.gov.tw/Mns/dos/content/Content.aspx?menu_id=6813

The import data of Taiwan for each detailed product category is downloaded from the WTO trade database at
https://www.wto.org/english/res_e/statis_e/statis_e.htm

* MATLAB CODE FOR PROCESSING THE DATA

To reproduce the key results for our benchmark model, we have included in the subfolder /Data/Matlab code/ the following four Matlab files

data_89.mat
data_91.mat
data_92.mat
data_93.mat

These four files are called by the Matlab script "data_moments.m" that when run computes the moments on concentration etc used for our calibration. These moments are saved in the file "saved_data_moments_march2015.mat" that is called by many of the other Matlab programs described below. 

* STATA CODE FOR PROCESSING THE DATA

We put our Stata ".do" files in the subfolder /Data/Stata code/. These are grouped into separate subfolders for the main text and the online Appendix. 

For the main text:

-- "sectoral_moments.do" replicates and checks the sectoral moments reported in Table 1. 
-- "trade_moments.do" produces additional moments related to export and imports in Table 1, including the import dispersion index, intraindustry trade index, regression coefficient of import share vs sales share, as well as aggregate export and import shares. Note that some of the results from this file were copied "by hand" directly to the Matlab script "data_moments.m" referred to above. 
-- "plant_moments.do" further produces plant-level concentration measures reported in Table 1.
-- "markup_moments.do" calculates the data projected markup distribution that we report in Table 2.

For the online Appendix, the subfolder DLW Markup has the files we use for calculating the alternative measures of markups using the IO methods of De Loecker and Warzynski (2012). In particular:

--	"prod_dlwg.m" and "obj_dlwg.m" are the Matlab codes we used to estimate production function for each 2-digit industries. It corresponds to the results we reported in Table A3.
-- "prod_est_g.csv" saves and reports all the estimates.
-- "markup_calc.do" reads in production function estimates and calculates markups for each plant in our data.
-- "markup_reg.do" regresses the measured inverse markups on observed producer market shares in detailed product categories, also reports the distribution of measured markups and "projected markups" in Table A4

Finally, the Appendix subfolder also contains "sectoral_moments_firm.do" which produces firm-level moments we report in Table A2.


I.2 BENCHMARK MODEL

In the folder /Benchmark model/ we put our Matlab code for solving the model:

-- "start.m" lists the parameter values and, in its default setting, first computes the autarky equilibrium, saves key values from autarky in the file "autarkysaved.mat", then re-solves for the equilibrium with trade and computes the gains from trade and other statistics.
-- "equilibrium.m" numerically solves for an equilibrium by iterating on the pricing and operating decisions of individual producers. 
-- "gumbel_copula.m" samples from a joint distribution linked by a Gumbel copula.
-- "trade_elasticity.m" numerically compute the trade elasticity.
-- "model_moments.m" computes the key moments from our model and compares them to their data counterparts [which are saved in "saved_data_moments_march2015.mat", which is producing using "data_moments.m" as discussed above]. 
-- "markup_moments.m" computes key moments of the unconditional and sectoral markup distribution in the model.
-- "domestic_and_import_markups" computes key moments of domestic and import markups separately.

II. ROBUSTNESS CHECKS AND SENSITIVITY ANALYSIS

The following are relatively minor variants on the benchmark model. Except where noted, all the programs work as in the benchmark model outlined in Section I above. 

II.1 BERTRAND COMPETITION

Same as benchmark model except that "start.m" has different calibrated parameter values and "equilibrium.m" is modified to account for the different expression for the demand elasticity with Bertrand competition (the benchmark model has Cournot competition).

II.2 ALTERNATE MODEL WITH CROSS-COUNTRY CORRELATION IN IDIOSYNCRATIC DRAWS

Same as benchmark model except that "start.m" has different calibrated parameter values and "equilibrium.m" is modified to account for the cross-country correlation in the idiosyncratic component of producer-level productivity (as well as in the sectoral component, as in the benchmark model). The cross-country correlation in idiosyncratic draws is controlled by the Kendall coefficient rho_x while the cross-country correlation in sectoral draws is controlled by the Kendall coefficient rho_z. The benchmark specification is obtained by setting rho_x=0. 

II.3 SENSITIVITY TO RHO

Each subfolder here contains "start.m" files corresponding to alternative values for the Kendall coefficient rho. 

II.4 LABOR WEDGES

Same as benchmark model except that "start.m" has different calibrated parameter values and has a new parameter, ltau, that controls the sensitivity of the labor wedge to producer-level productivity, "equilibrium.m" is modified to account for the labor wedge, and "model_moments.m" is modified to measure producer-level labor shares correctly. 

II.5 HETEROGENEOUS TARIFFS

Same as benchmark model except that "start.m" has different calibrated parameter values and has two new parameters, tarrif_a and tariff_b, governing the sectoral distribution of tariffs, "equilibrium.m"  is modified to account for the distortionary tariffs as is the calculation of the trade elasticity in "trade_elasticity.m".

II.6 SENSITIVITY TO GAMMA

Contains two subfolders, corresponding to values gamma=5 and gamma=20 for the within-sector elasticity of substitution. Each "start.m" file has different calibrated parameter values corresponding to these alternate values for gamma.

II.7 NO FIXED COSTS

Same as benchmark model except that "start.m" has different calibrated parameter values.

II.8 GAUSSIAN COPULA

Same as benchmark model except that "start.m" has different calibrated parameter values and "equilibrium.m" calls the Matlab script "gaussian_copula.m" to sample from a Gaussian copula rather than the benchmark Gumbel copula. 

II.9 UNCORRELATED NUMBER OF PRODUCERS

Same as benchmark model except that "start.m" has different calibrated parameter values and has a new parameter rho_n that controls the amount of cross-country correlation in the number of (potential) producers per sector (the benchmark specification corresponds to rho_n=1) and "equilibrium.m" is modified accordingly. In particular, for this experiment rho_n=0. 

II.10 5-DIGIT SECTORS

Same as benchmark model except that "start.m" has different calibrated parameter values (to reflect calibration to sectoral data aggregated to 5-digits). 

II.11 N COMPETITORS PER SECTOR  

Same as benchmark model except that there is a fixed N competitors per sector (rather than the geometric distribution with parameter zeta as there is in the benchmark model) and "start.m" and "equilibrium.m" have been modified accordingly. 

III. EXTENSIONS

The following extensions involve more elaborate departures from the benchmark model. 

III.1 CAPITAL ACCUMULATION AND ELASTIC LABOR SUPPLY

-- "elastic_factors.m" specifies parameter values for the model with capital accumulation and elastic labor supply and specifies the levels of aggregate productivity and the level of the aggregate markup (which acts as a distortionary tax wedge) for both an initial and a terminal steady state. Note that the weight on leisure in the utility function is chosen to normalize labor supply to L=1 in the terminal steady state.
-- "elastic_factors_steady_state.m" computes the steady state values of consumption, capital etc given the parameters.
-- "elastic_factors_transitional_dynamics.m" is a function that, when zeroed out, gives the time path of consumption C(t) and capital K(t) that solve the transitional dynamics from the initial to terminal steady state. This function is zeroed out using the nonlinear least squares solver from the Matlab optimization toolbox. 

III.2 ASYMMETRIC COUNTRIES

For these experiments, "start.m" has two additional parameters, Ls and Abars, that specify the labor force and productivity level of the Foreign country relative to the Home country. The script "equilibrium.m" in this subfolder allows for these asymmetries in size and productivity levels and there is a separate script "equilibrium_autarky.m" for more efficiently computing the autarky equilibrium for these experiments. Finally, there are new scripts "model_moments_asymmetric.m" and "markup_moments_asymmetric.m" that reports key statistics for the Home and Foreign countries separately. 

III.3 FREE ENTRY 

Each subfolder records one of the free entry experiments. "start.m" now uses the alternative parameterization that we adopt for our free entry and collusion experiments. See the detailed notes below on reproducing the tables for these experiments.

IV. REPRODUCING TABLES IN THE MAIN TEXT

The following are detailed notes on reproducing all the tables in the main text. 

* TABLE 1. PARAMETERIZATION

The data moments shown in Panel A are produced using the Matlab and Stata code outlined in Section I.1. The key moments used for the calibration can be reproduced using the Matlab code "data_moments.m" which are then stored in "saved_data_moments_march2015.mat". The model moments in Panel A are obtained by running the script "model_moments.m" after computing the equilibrium for the benchmark model, as described in Section I.2 above. Likewise, the parameter values shown in Panel B are the parameters listed in "start.m" for the benchmark model, as described above.

* TABLE 2. MARKUPS IN DATA AND MODEL

The first column are our measures of markups (inverse labor shares) from the Taiwanese data. These are obtained using the Stata program "markup_moments.do" as discussed in Section I.1 above. The next two columns are obtained by running the script "markup_moments.m" after computing the equilibrium for the benchmark model, as described in Section I.2 above. The last two columns are obtained by running the script "markup_moments" after computing the equilibrium for the Bertrand model, as described in Section II.1 above.

* TABLE 3. GAINS FROM TRADE

The results in Panel A are obtained by computing the equilibrium of the benchmark model for different settings of the trade cost tau with tau chosen to induce trade shares of 0% (autarky), 10%, 20%, 30% and 37.5% (corresponding to the Taiwan calibration). Specifically, to obtain:

import share = 0.000, we use tau = 100000 (autarky)
import share = 0.100, we use tau = 0.715
import share = 0.200, we use tau = 0.410
import share = 0.300, we use tau = 0.2315
import share = 0.375, we use tau = 0.1285 (corresponds to benchmark Taiwan calibration)

Note that these calculations give the *levels* of aggregate productivity, markups, etc. The results shown in Table 3 are for the *changes* from one level to the next (e.g., from autarky to a 10% import share, or from 10% to 20%, etc).

The results in Panel B are likewise obtained by computing the equilibrium of the alternate model with cross-country correlation in idiosyncratic draws, as described in Section II.2 above, for different settings of the trade cost tau. Specifically, to obtain:

import share = 0.000, we use tau = 100000 (autarky)
import share = 0.100, we use tau = 0.710
import share = 0.200, we use tau = 0.409
import share = 0.300, we use tau = 0.234
import share = 0.375, we use tau = 0.1285 (corresponds to alternate calibration)

* TABLE 4. IMPORTANCE OF HEAD-TO-HEAD COMPETITION

Each row in Panel A corresponds to an alternative calibration of our model where we set the Kendall coefficient rho to the listed value and then recalibrate our remaining parameters, as in the subfolders referred to in Section II.3 above

Panel B shows more detail for the cases rho=0.1 and rho=0.9 with the extra statistics computed using the Matlab script "domestic_and_import_markups.m".

* TABLE 5. GAINS FROM TRADE WITH ELASTIC FACTORS

These results are obtained using the Matlab scripts described in section III.1 above which compute the transitional dynamics of a growth model with elastic labor supply between an initial and a terminal steady state.

The first column reports results when productivity increases permanently from A = 25.377 to 28.1722, an increase of 10.4% corresponding to the increase in *first-best* productivity from autarky to the benchmark Taiwan calibration while the aggregate markup stays constant at its autarky level. The remaining columns report results when (i) productivity increases permanently from A = 23.204 to 26.274, an increase of 12.4% corresponding to the increase in *actual* productivity from autarky to the Taiwan calibration while (ii) the aggregate markup falls permanently from mu = 1.353 to 1.314, a decrease of 2.9%. Results for several different elasticities of labor supply are reported (corresponding to different settings of the parameter eta in the script "elastic_factors.m")

The values for aggregate productivity and the aggregate markup are computed as in the benchmark model described in Section I above. 

* TABLE 6. ROBUSTNESS EXPERIMENTS

Each column summarises key features of one of the calculations discussed above. The first column gives results for the benchmark model as in Section I.2, the model with labor wedges as in Section II.4, the model with heterogeneous tariffs as in Section II.5, the model with Bertrand competition as in section II.1, the models with low and high values for gamma as in Section II.6, the model with no fixed costs as in Section II.7, and the model with a Gaussian copula to model cross-country correlation in sectoral draws as in Section II.8. In each case, the values for the aggregate and average labor share are computed using "model_moments.m". The other statistics are simply produced by running the respective "start.m" script.   

* TABLE 7. GAINS FROM TRADE WITH ASYMMETRIC COUNTRIES

These results are obtained using the Matlab scripts described in Section III.2 above which compute the equilibrium for our model when the two countries are asymmetric in the size of the labor force and/or aggregate productivity. Panel A reports results for Foreign labor supply Ls=2 and Ls=10 times that of Home. Panel B reports results for Foreign productivity Abars=2 and Abars=10 times that of Home. 

All asymmetric country experiments have the benchmark parameters except that for:

Ls = 2      we use tau = 0.245, rho = 0.94425             
Ls = 10     we use tau = 0.50 , rho = 0.955225             

and for

Abars = 2   we use tau = 0.32, rho = 0.86    , fx = 0.25, gamma = 10.25
Abars = 10  we use tau = 1.66, rho = 0.59975 , fx = 0.30, gamma = 10.25

Other statistics for these experiments are computed using "model_moments_asymmetric.m" and "markup_moments_asymmetric.m". 

* TABLE 8. ENTRY AND COLLUSION 

To replicate Panel A, first run "start.m" from the subfolder "/Gains trade free entry/No collusion autarky". The output of the command window can be used to fill the Autarky column of the panel. Also save the level of productivity, A, from this experiment.

To replicate the Free Entry column of Panel A, run "start.m" in the subfolder "/Gains trade free entry/no collusion".  Use the output of the command window to fill in the corresponding entries in the Free Entry column. To compute the gains from trade, simply calculate the % difference between the level of aggregate productivity in this economy and the one saved rom the autarky experiment described above. 

To replicate the No Entry column of Panel A, run "start.m" in the subfolder "/Gains trade free entry/No collusion" but set N equal to 187 (as opposed to 168) in the Free Entry column. 

Follow a similar approach to reproduce Panel B using the "/Gains trade free entry/Collusion 25" and "Gains trade free entry/Collusion 25 autarky" folders. 

V. REPRODUCING TABLES IN THE ONLINE APPENDIX

* TABLES A1, A2, A3, A4

Table A1 is an example of from the Standard Industrial Classification created by the Taiwanese Statistical Bureau. Table A2 Reports plant- and firm-level concentration moments, these are obtained using the Stata code "plant_moments.do" and "sectoral_moments_firm.do" as described in Section I.1 above. Likewise, Table A3 reports production function estimates obtained using the Matlab code "prod_dlwg.m" and "obj_dlwg.m" and Table A4 reports measures of markups obtained using "markup_calc.do" and "markup_reg.do", as described in Section I.1 above.

* TABLES A5, A6, A7

Table A5 lists the parameter values for each robustness experiment as per the "start.m" scripts described in Section II above. Likewise, Table A6 records the moments implied by each model obtained after running "model_moments.m" in the relevant subfolder after the equilibrium of each model has been computed. Table A7 reports the gains from trade directly computed by each "start.m" file as well as some key markup moments obtained after running "markup_moments.m" in the relevant subfolder after the equilibrium of each model has been computed. The average/aggregate labor share row in Table A7 is obtained from "model_moments.m".

* TABLE A8

Table A8 records key statistics for each of the fixed N experiments as per the "start.m" script described in Section II.11 above. For N=1,2,10,20 we record results for autarky and for free trade (i.e., tau=fx=0) for both independent (rho=0) and perfectly dependent (rho=1) sectoral productivity draws. Panel A reports results when there is no idiosyncratic productivity draw (all producers within a sector have identical productivity). Panel B reports results when there are idiosyncratic productivity draws (as in our benchmark specification). 

* TABLE A9 

Table A9 records results for the model with capital accumulation and elastic labor supply as per the scripts described in Section III.1 above. The procedure to obtain these results is as described for Table 5 in the main text (see Section IV above).  

* TABLES A10, A11, A12

Table A10 lists the parameter values for each asymmetric countries experiment as per the "start.m" scripts described in Section III.2 above. Likewise, Table A11 records the moments implied by each model obtained after running "model_moments_asymmetric.m" in the relevant subfolder after the equilibrium of each model has been computed. Table A12 reports the gains from trade and directly computed by each "start.m" file as well as some key markup moments obtained after running "markup_moments_asymmetric.m" in the relevant subfolder after the equilibrium of each model has been computed. 

* TABLES A13, A14, A15

Table A13 lists the parameter values for each free entry experiment as per the "start.m" scripts in each subfolder. Table A14 records the moments implied by each model. These are obtained using the subfolder "/Moments free entry" for each model. Table A15 records the gains from trade for each model. The procedure to obtain these results is as described for Table 8 in the main text (see Section IV above).  














